
SET( LUA_QT_H    config.h
                 luaQt.h
                 luaQPen.h
                 luaQColor.h
			     #luaQtUI.h
			   )
SET( LUA_QT_CPP  luaQt.cpp
#                          luaQ2DViewerUI.cpp
			    lua/luaQPen.cpp
			    lua/luaQColor.cpp
			    lua/luaQString.cpp
			    lua/luaQFont.cpp
			    lua/luaQBrush.cpp
			    #lua/toluaQPen.cpp
			    #lua/toluaQColor.cpp
			    #lua/toluaQString.cpp
			    #lua/toluaQFont.cpp
			    #lua/toluaQBrush.cpp
			    )
INCLUDE_DIRECTORIES(  ${SOL2_INCLUDE_DIR} )

INCLUDE_DIRECTORIES(  ${LUAEx_SOURCE_DIR} )
INCLUDE_DIRECTORIES(  ${MYLIB_DIR} )
INCLUDE_DIRECTORIES(  ${Boost_INCLUDE_DIR} )
INCLUDE_DIRECTORIES(  ${LUA_INCLUDE_DIR} )
##INCLUDE_DIRECTORIES(  ${TOLUA++_INCLUDE_DIR} )

LINK_DIRECTORIES( ${MYLIB_LIB_DIR} )
LINK_DIRECTORIES( ${Boost_LIBRARY_DIR} )
LINK_DIRECTORIES( ${Boost_LIBRARY_DIR_RELEASE} )
set (QT_USE_QTOPENGL TRUE)
set (QT_USE_QTCORE TRUE)
include(AddFileDependencies)

message( "Qt used" )
if(Qt5_FOUND)
#	qt5_generate_moc( Q2DViewer.h "${CMAKE_CURRENT_BINARY_DIR}/Q2DViewer_moc.cpp" )
#	add_file_dependencies( Q2DViewer_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Q2DViewer.h" )
#	qt5_add_resources ( RESOURCE_FILES q2DViewer.qrc )
#	qt5_wrap_ui( UI_FILES ./ui/QMainWindow.ui
#                      ./ui/SettingsDialog.ui)
elseif(Qt4_FOUND)
    message( "Qt4 used" )
	include(${QT_USE_FILE})
#    qt4_generate_moc( Q2DViewer.h "${CMAKE_CURRENT_BINARY_DIR}/Q2DViewer_moc.cpp" )
#	add_file_dependencies( Q2DViewer_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Q2DViewer.h" )
#	qt4_add_resources ( RESOURCE_FILES q2DViewer.qrc )
endif()

INCLUDE_DIRECTORIES(  ${QT_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} )


set(LUA_QT_ALLFILES ${LUA_QT_H}
                                 ${LUA_QT_CPP}
				 #${CMAKE_CURRENT_BINARY_DIR}/Q2DViewer_moc.cpp
				 #${RESOURCE_FILES}
				 #${UI_FILES}
				 )

if(Q2DVIEWER_STATIC_LIB)
	ADD_LIBRARY(luaQt STATIC ${LUA_QT_ALLFILES})
else()
	ADD_LIBRARY(luaQt SHARED ${LUA_QT_ALLFILES})
    if(WIN32)
        add_definitions( -DluaQt_DLL )
    endif()
endif()

if(Qt5_FOUND)
    qt5_use_modules(luaQt Core Gui OpenGL )
elseif(Qt4_FOUND)
    qt4_use_modules(luaQt Core Gui OpenGL )
endif()


target_link_libraries(luaQt  ${LUA_LIBRARIES})
target_link_libraries(luaQt	 ${QT_LIBRARIES}
								 ${OPENGL_LIBRARIES}
								 )
if(WIN32 OR APPLE)
	#target_link_libraries(luaQt ${TOLUA++_LIBRARY} )
        #target_link_libraries(luaQt ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY})
	#target_link_libraries(luaQt ${Boost_THREAD_LIBRARY}  ${Boost_REGEX_LIBRARY} ${Boost_SYSTEM_LIBRARY})
endif()

SET_TARGET_PROPERTIES(luaQt PROPERTIES CLEAN_DIRECT_OUTPUT 1)
SET_TARGET_PROPERTIES(luaQt PROPERTIES PREFIX "")
collect_library(luaQt)
